﻿using System.Data.Entity;

namespace TrackMe.Backend.Entities
{
    class TimeTrackContext : DbContext
    {
        static TimeTrackContext()
        {
            Database.SetInitializer(new CreateDatabaseIfNotExists<TimeTrackContext>());
        }

        public TimeTrackContext() : base("Data Source=.;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=TimeTrack")
        {
        }

        public DbSet<Job> Jobs { get; set; }
        public DbSet<Project> Projects { get; set; }
        public DbSet<User> Users { get; set; }
        public DbSet<Task> Tasks { get; set; }
        public DbSet<TfsServer> TfsServers { get; set; }
        public DbSet<JobInProgress> JobsInProgress { get; set; }
        public DbSet<JobToClockOut> JobsToClockOut { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new JobMap());
            modelBuilder.Configurations.Add(new ProjectMap());
            modelBuilder.Configurations.Add(new UserMap());
            modelBuilder.Configurations.Add(new TaskMap());
            modelBuilder.Configurations.Add(new TfsServerMap());
            modelBuilder.Configurations.Add(new JobInProgressMap());
            modelBuilder.Configurations.Add(new JobToClockOutMap());
        }
    }
}
